/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cs575.dbentities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bms
 */
@Entity
@Table(name = "group", catalog = "tasks_management", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GroupEx.findAll", query = "SELECT g FROM GroupEx g"),
    @NamedQuery(name = "GroupEx.findByGroupId", query = "SELECT g FROM GroupEx g WHERE g.groupId = :groupId"),
    @NamedQuery(name = "GroupEx.findByGroupName", query = "SELECT g FROM GroupEx g WHERE g.groupName = :groupName")})
public class GroupEx implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "privateGroup", fetch = FetchType.LAZY)
    private List<User> userList;
    private static final long serialVersionUID = 1L;
    
    @TableGenerator(name="Group_Gen", table="ID_GEN", pkColumnName="GEN_NAME", valueColumnName="GEN_VAL")
    @Id @GeneratedValue(generator="Group_Gen")    
    @Basic(optional = false)
    @Column(name = "group_id", nullable = false)
    private Integer groupId;
    @Basic(optional = false)
    @Column(name = "group_name", nullable = false, length = 100)
    private String groupName;
    @Basic(optional = false)
    @Lob
    @Column(name = "group_description", nullable = false, length = 65535)
    private String groupDescription;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "groupEx", fetch = FetchType.LAZY)
    private List<GroupMember> groupMemberList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "groupId", fetch = FetchType.LAZY)
    private List<Task> taskList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "groupEx", fetch = FetchType.LAZY)
    private List<GroupInvitation> groupInvitationList;

    public GroupEx() {
    }

    public GroupEx(Integer groupId) {
        this.groupId = groupId;
    }
    public GroupEx(String groupName, String groupDescription) {
        this.groupName = groupName;
        this.groupDescription = groupDescription;
    }
    
    public GroupEx(Integer groupId, String groupName, String groupDescription) {
        this.groupId = groupId;
        this.groupName = groupName;
        this.groupDescription = groupDescription;
    }
    
    public String getGroupDescription() {
        return groupDescription;
    }

    public void setGroupDescription(String groupDescription) {
        this.groupDescription = groupDescription;
    }

    public Integer getGroupId() {
        return groupId;
    }

    public void setGroupId(Integer groupId) {
        this.groupId = groupId;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
    

    @XmlTransient
    public List<GroupMember> getGroupMemberList() {
        return groupMemberList;
    }

    public void setGroupMemberList(List<GroupMember> groupMemberList) {
        this.groupMemberList = groupMemberList;
    }

    @XmlTransient
    public List<Task> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<Task> taskList) {
        this.taskList = taskList;
    }

    @XmlTransient
    public List<GroupInvitation> getGroupInvitationList() {
        return groupInvitationList;
    }

    public void setGroupInvitationList(List<GroupInvitation> groupInvitationList) {
        this.groupInvitationList = groupInvitationList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (groupId != null ? groupId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GroupEx)) {
            return false;
        }
        GroupEx other = (GroupEx) object;
        if ((this.groupId == null && other.groupId != null) || (this.groupId != null && !this.groupId.equals(other.groupId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cs575.dbentities.GroupEx[ groupId=" + groupId + " ]";
    }

    @XmlTransient
    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }
    
}
